package com.myCinema.dao.impl;

import java.util.List;

import org.hibernate.Session;
import org.hibernate.Transaction;

import com.myCinema.dao.DeptDao;
import com.myCinema.entity.Dept;
import com.myCommunity.dao.HibernateUtil;

public class DeptDaoImpl implements DeptDao {

	public List<Dept> getAll() {
		Session sess = null;
		try{
			sess = HibernateUtil.openSession();
			return sess.createQuery("from Dept").list();
		}finally{
			sess.close();
		}
	}

	public void delete(int deptId) {
		Session sess = null;
		try{
			sess = HibernateUtil.openSession();
			Transaction tx = sess.beginTransaction();
			Dept d = (Dept) sess.get(Dept.class, deptId);
			sess.delete(d);
			tx.commit();
		}finally{
			sess.close();
		}
		
	}

}
